package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.WdyWalletCollect;
import com.ruoyi.system.service.IWdyWalletCollectService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 钱包汇总 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-03-08
 */
@Controller
@RequestMapping("/system/wdyWalletCollect")
public class WdyWalletCollectController extends BaseController
{
    private String prefix = "system/wdyWalletCollect";
	
	@Autowired
	private IWdyWalletCollectService wdyWalletCollectService;
	
	@RequiresPermissions("system:wdyWalletCollect:view")
	@GetMapping()
	public String wdyWalletCollect()
	{
	    return prefix + "/wdyWalletCollect";
	}
	
	/**
	 * 查询钱包汇总列表
	 */
	@RequiresPermissions("system:wdyWalletCollect:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WdyWalletCollect wdyWalletCollect)
	{
		startPage();
        List<WdyWalletCollect> list = wdyWalletCollectService.selectWdyWalletCollectList(wdyWalletCollect);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出钱包汇总列表
	 */
	@RequiresPermissions("system:wdyWalletCollect:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WdyWalletCollect wdyWalletCollect)
    {
    	List<WdyWalletCollect> list = wdyWalletCollectService.selectWdyWalletCollectList(wdyWalletCollect);
        ExcelUtil<WdyWalletCollect> util = new ExcelUtil<WdyWalletCollect>(WdyWalletCollect.class);
        return util.exportExcel(list, "wdyWalletCollect");
    }
	
	/**
	 * 新增钱包汇总
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存钱包汇总
	 */
	@RequiresPermissions("system:wdyWalletCollect:add")
	@Log(title = "钱包汇总", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WdyWalletCollect wdyWalletCollect)
	{		
		return toAjax(wdyWalletCollectService.insertWdyWalletCollect(wdyWalletCollect));
	}

	/**
	 * 修改钱包汇总
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		WdyWalletCollect wdyWalletCollect = wdyWalletCollectService.selectWdyWalletCollectById(id);
		mmap.put("wdyWalletCollect", wdyWalletCollect);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存钱包汇总
	 */
	@RequiresPermissions("system:wdyWalletCollect:edit")
	@Log(title = "钱包汇总", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WdyWalletCollect wdyWalletCollect)
	{		
		return toAjax(wdyWalletCollectService.updateWdyWalletCollect(wdyWalletCollect));
	}
	
	/**
	 * 删除钱包汇总
	 */
	@RequiresPermissions("system:wdyWalletCollect:remove")
	@Log(title = "钱包汇总", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wdyWalletCollectService.deleteWdyWalletCollectByIds(ids));
	}
	
}
